package com.christina.engine.decision.model;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 决策结果模型
 * 
 * @author Christina
 */
@Data
@Builder
public class DecisionResult {
    
    /**
     * 决策ID
     */
    private String decisionId;
    
    /**
     * 决策动作
     */
    private DecisionAction action;
    
    /**
     * 目标服务
     */
    private String targetService;
    
    /**
     * 执行参数
     */
    private JSONObject executionParameters;
    
    /**
     * 决策置信度
     */
    private double confidence;
    
    /**
     * 决策理由
     */
    private String reasoning;
    
    /**
     * 备选方案
     */
    private List<AlternativeOption> alternatives;
    
    /**
     * 决策时间
     */
    private LocalDateTime decisionTime;
    
    /**
     * 预期执行时间
     */
    private long expectedExecutionTime;
    
    /**
     * 决策状态
     */
    private DecisionStatus status;
    
    /**
     * 决策动作
     */
    @Getter
    public enum DecisionAction {
        EXECUTE_SERVICE("执行服务"),
        DELEGATE_TO_HUMAN("转人工处理"),
        REQUEST_MORE_INFO("请求更多信息"),
        PROVIDE_SUGGESTIONS("提供建议"),
        SCHEDULE_TASK("安排任务"),
        SEND_NOTIFICATION("发送通知"),
        UPDATE_CONTEXT("更新上下文"),
        END_CONVERSATION("结束对话");
        
        private final String description;
        
        DecisionAction(String description) {
            this.description = description;
        }

    }
    
    /**
     * 决策状态
     */
    @Getter
    public enum DecisionStatus {
        PENDING("待执行"),
        EXECUTING("执行中"),
        COMPLETED("已完成"),
        FAILED("执行失败"),
        CANCELLED("已取消");
        
        private final String description;
        
        DecisionStatus(String description) {
            this.description = description;
        }

    }
    
    /**
     * 备选方案
     */
    @Data
    @Builder
    public static class AlternativeOption {
        private String optionId;
        private String description;
        private DecisionAction action;
        private Map<String, Object> parameters;
        private double score;
        private String pros;
        private String cons;
    }
}